package org.dao.serviceprovide;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.home.Owner.OwnerInfo;
import org.mapdatabase.hibernate.tables.OwnerTable;



public class OwnerDao extends DaoUtils{

	public  void callOwnerDetails(){
		OwnerDao dao = new OwnerDao();
		Session session = dao.create(null, OwnerTable.class);
	    session.beginTransaction();
		List<OwnerInfo> list = session.createQuery("from OwnerTable").list();
	}
	
	public  OwnerTable reteriveOwnerInfoById (int ownerId){
		OwnerDao dao = new OwnerDao();
		Session session = dao.create(null, OwnerTable.class);
	    Transaction beginTransaction = session.beginTransaction();
	    String query = "from OwnerTable where ownerId =:id" ;
	    Query createQuery = session.createQuery(query);
		createQuery.setInteger("id", ownerId);
        Object queryResult = createQuery.uniqueResult();
		OwnerTable owner =(OwnerTable)queryResult;
		return owner;
		
	}
}
